<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
       $this->display();
        }
    public function login(){
       $this->display();
        }
    public function login_handler(){
      $account = I("post.username");
      $password =I("post.password");
      
      $User = M("Admin");
      $condition['account'] = $account;
      $condition['password'] = $password;
      
      $result = $User->where($condition)->select();
      if($result){
          $this->redirect('index');
          //测试模板继承
      public function test(){
          $this ->display();
      }
      }else{
          $this->error("用户名或密码错误！");
              
      }
      
              
        }
public function checkusername(){
    $account = I('post.username');
    $db = M('Admin');
    $condition['account'] =$account;
    $cnt = $db->where($condition)->count();
    if($cnt>0){
        echo  1;
    }else{
        echo 0;
    }
}
public function checkpassword(){
  $account = I('post.username');
  $password = I('post.password');
  
  $db =M('Admin');
  $condition['account'] =$account;
  $condition['password'] =$password;
  $cnt = $db->where($condition)->count();
   if($cnt>0){
       echo 1;
   }else{
       echo 0;
   }
  
}
}